﻿using BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Model;

namespace LandAppraisal.Controllers
{
    public class AssessmentController : ApiController
    {
        AdminBLL bll = new AdminBLL();

        #region 获取评估列表
        /// <summary>
        /// 获取评估列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public string GetAssessmentList(string option, string optionchild)
        {
            if (option != "请选择" && optionchild != "请选择")
            {
                if (option == "The_Department")
                {
                    var list = bll.RegisterList().Where(x => x.Basic_State == 2)
                        .Where(p => p.The_Department == optionchild);
                    return JsonConvert.SerializeObject(list);
                }
                if (option == "ProjectNumber")
                {
                    var list = bll.RegisterList()
                        .Where(x => x.Basic_State == 2).Where(p => p.ProjectNumber == optionchild);
                    return JsonConvert.SerializeObject(list);
                }
                if (option == "Loan_Name")
                {
                    var list = bll.RegisterList().Where(x => x.Basic_State == 2)
                        .Where(p => p.Loan_Name == optionchild);
                    return JsonConvert.SerializeObject(list);
                }
                if (option == "House_Located")
                {
                    var list = bll.RegisterList().Where(x => x.Basic_State == 2)
                                                .Where(p => p.House_Located == optionchild);
                    return JsonConvert.SerializeObject(list);
                }
            }
            return JsonConvert.SerializeObject(bll.RegisterList().Where(x => x.Basic_State == 2));
        }
        #endregion

        #region 根据项目号查询相关信息
        /// <summary>
        /// 根据项目号查询相关信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string GetAssessmentByProjectNumber(string ProjectNumber)
        {
            return JsonConvert.SerializeObject(bll.GetAssessmentProjectNumber<EABasic_Info>(ProjectNumber));
        }
        #endregion

    }
}
